<?php
/**
 * ------------------------------------------------------------------------
 * JA Disqus Debate Echo plugin for Joomla 2.5
 * ------------------------------------------------------------------------
 * Copyright (C) 2004-2011 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
 * @license - GNU/GPL, http://www.gnu.org/licenses/gpl.html
 * Author: J.O.O.M Solutions Co., Ltd
 * Websites: http://www.joomlart.com - http://www.joomlancers.com
 * ------------------------------------------------------------------------
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

//JS-Kit config
$domain         = $this->plgParams->get('provider-jskit-domain');


$sefPath = $this->_sefpath;
$sefUrl = $this->_sefurl;
if ($this->isComment == false) {
	if (!defined('JACOMMENT_COUNT')) :
		$headscript = "
			<script type='text/javascript'>
			//<![CDATA[
			window.addEvent('domready', function(){
				var aCountComments = $$('span.js-kit-comments-count');
				if(aCountComments.length > 0) {
					Asset.javascript('http://js-kit.com/for/".$domain."/comments-count.js', {charset: 'utf-8'});
				}
			});
			//]]>
			</script>
		";
		$this->document->addCustomTag($headscript);
		define('JACOMMENT_COUNT',1);
	endif;
?>
	<div class="jacomment-count"><a href="<?php echo $this->_path; ?>"><?php echo JText::_("COMMENTS"); ?> (<span class="js-kit-comments-count" uniq="<?php echo $sefPath; ?>">0</span>)</a></div>
<?php } else { ?>
	<div class="js-kit-comments" permalink="<?php echo $sefUrl;?>" path="<?php echo $sefPath;?>"></div>
	<script type="text/javascript" src="http://js-kit.com/for/<?php echo $domain?>/comments.js"></script>
<?php } ?>